Askrene and xpay improve#9150
Conversation
|
|
||
| /* Apply any intel we have, in order */ | ||
| intelarr = channel_intel_hash_get(layer->channel_intels, scidd->scid); | ||
| for (size_t i = 0; i < tal_count(intelarr); i++) { |
There was a problem hiding this comment.
Since we are using impressions to deduce information for the other direction of the channel, we might as well use the constraints in the same way.
When we know the liquidity L on one side is in the range [a,b], we deduce the liquidity L' on the other side is in the range [C-b, C-a], where C is the capacity of the channel.
Therefore this for loop could be written as this:
for (size_t i = 0; i < tal_count(intelarr); i++) {
if (intelarr[i].constraint) {
const struct constraint *c = intelarr[i].constraint;
if (c->scidd.dir == scidd->dir) {
*min = amount_msat_max(*min, c->min);
*max = amount_msat_min(*max, c->max);
} else {
*min = amount_msat_max(*min, capacity - c->max);
*max = amount_msat_min(*max, capacity - c->min);
}
} else {
const struct impression *imp = intelarr[i].impression;
/* We made payment along this channel? Capacity has reduced */
if (imp->scidd.dir == scidd->dir) {
if (!amount_msat_sub(min, *min, imp->amount))
*min = AMOUNT_MSAT(0);
if (!amount_msat_sub(max, *max, imp->amount))
*max = AMOUNT_MSAT(0);
} else {
/* We made the other way? Capacity has increased */
if (!amount_msat_add(min, *min, imp->amount))
*min = AMOUNT_MSAT(-1ULL);
if (!amount_msat_add(max, *max, imp->amount))
*max = AMOUNT_MSAT(-1ULL);
}
}
}
It is not wrong the way it is now.
I am just saying we could exploit a little bit more the information we have available.
| if (intelarr[i].constraint) { | ||
| const struct constraint *c = intelarr[i].constraint; | ||
| if (c->scidd.dir == scidd->dir) { | ||
| *min = amount_msat_max(*min, c->min); |
There was a problem hiding this comment.
There is something else here. I am thinking that contradictory information can happen,
ie. a more recent channel intel does not simply increases our knowledge but it also
invalidates a previous intel.
For example: min was 0 (unspecified) and max was 100 at timestamp 0, but then at timestamp 1
we encounter min is 110 and max is MAX_UINT64 (unspecified). Applying min max we update
that min = 110 and max = 100, so in this case a contradiction leads to min>max.
I think can solve this by giving precedence to the most recent constraint.
So that in our example the contradictory min=110 moves upwards the current min but also the current max.
You already handled the contradictory impressions case by checking if min<impression then
min = 0, and if max<impression then max=0.
|
Overall I like the improvements introduced in this PR. In this way we delegate the interpretation to the moment when we call getroutes: |
Shades of `efacada7ddf` which did the same thing in multifundchannel:
(ab)used the id, which being a string, gave and id of 34 (").
Also clean up the leftover assert in multifundchannel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We used to handle it being a literal, but this was removed in 73fc9b0 (v25.05) so we don't need to handle that at all. Not using the raw JSON means we handle weird methodnames by replacement: otherwise we would not match the responses. Only an issue for commando, where the command would time out rather than report "Unknown method". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…ngs. In particular, "struct jsonrpc_request"'s id is always a string. cmd->id isn't, though. We can also remove the now-unused json_get_id. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We have three uses already, about to add a fourth. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
The prior implementation could read past the end of the buffer (we actually pad our JSON so this isn't harmful, but still). Fix up json_to_s64 and json_to_double too, but since they're not used as often, just copy the string there. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Currently used for offers, we will use it for repeatpay too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Normal constraints are clamps on min/max caused by failed payments: min for the channels that succeeded, max for the channel which failed. Impressions are the results of successful payments, which alter both min and max (negatively in the forward direction, positively in the reverse). impression: n 1. An effect, feeling, or image retained as a consequence of experience. 2. A vague notion, remembrance, or belief. 3. A mark produced on a surface by pressure. Unlike constraints, this is the result of our own effect on the network: they're related but different enough to get their own API and terminology. The name conveys both we made an impression on the channel, and that the results are a bit vague (due to other changes since then, which we won't know about). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `askrene` layers now contain "impressions" representing the effects of successful payments we made through channels.
…n downgrading to v26.06. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Pure "constraints" don't care about order (they simply clamp max and min), but "impressions" are relative, so they do. Change the hashtable to keep them timestamp sorted. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
from a tal array. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
On deletion of individual channel intel entries we need to free the pointer inside the structure. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
It diagnoses if the *total capacity* of the source/dest are insufficient, but not if the *known capacity* is. So we get: The shortest path is 103x1x0->105x1x0, but 103x1x0/1 layer auto.localchans says max is 77704899msat Whereas it would be better to do: We know from auto.localchans that source has maximum capacity xxx msat (in 1 channels) Similarly for the destination, we get: The shortest path is 103x1x0->105x1x0, but 103x1x0/1 layer auto.localchans says max is 77704899msat
Add PAY_INSUFFICIENT_FUNDS and PAY_ROUTE_NOT_FOUND, and give nice detailed errors for those. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Changed: JSON-RPC: `getroutes` can now return PAY_INSUFFICIENT_FUNDS (215) and PAY_DESTINATION_INSUFFICIENT_CAPACITY (220) error codes.
…rrencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…ersion. This mirrors the previous commit, where we did it for recurring offers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: Offers: we set a 10 minute expiry when we create invoices for offers in other currencies.
We don't actually need to enforce this check here: we can make that the users' responsibility. This simplifies our work quite a lot, since createinvoicerequest won't have to do a lookup any more. This can be done by the repeatpay plugin itself. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This is an undocumented interface, so we can just change it. Rename "recurrence_label" to the more general "label", now we don't require it to find previous payments. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9b3f051 to
7bddd3b
Compare
|
Depends on #9138
This prepwork for repeatpay improves askrene and xpay: